﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace NinjaToolbox.PhysicsSystem
{
    public class ColliderObject : PhysicsBase
    {
        public bool registToManager = true;
        public bool alwaysVisibleGizmos = true;
        public bool isDrawGizmos = true;


        void OnEnable()
        {
            if (registToManager)
                PhysicsSystemManager.Instance.RegistColliderObject(this);
        }

        void OnDisable()
        {
            if (registToManager && PhysicsSystemManager.Instance != null)
                PhysicsSystemManager.Instance.UnregistColliderObject(this);
        }

        void OnDrawGizmos()
        {
            if (!alwaysVisibleGizmos) return;

            DrawGizmos();
        }

        void OnDrawGizmosSelected()
        {
            if (alwaysVisibleGizmos) return;

            DrawGizmos();
        }

        void DrawGizmos()
        {
            if (!isDrawGizmos) return;

            DrawShapeGizmos();
        }

        void DrawShapeGizmos()
        {
            PhysicsShape.DrawGizmos(PhysicsUtil.PHYSICS_SHAPE_GIZMOS_COLOR);
        }
    }
}
